package com.qianxun.entrace.filter;

import com.qianxun.entrace.service.UserAccessLoggerService;
import com.qianxun.plugins.log.LogPoint;
import com.qianxun.plugins.log.LogParam;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.IOException;


/**
 * 用户访问过滤器，用于记录用户的请求信息
 * @author: huwei
 * @date: 2019/10/17 14:59
 * @version: 1.0.0
 */
@Component
public class AccessFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    @LogPoint(title = "记录用户访问" ,key = "user_access" ,logger = UserAccessLoggerService.class)
    public void doFilter(@LogParam(value = "request") ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        filterChain.doFilter(servletRequest ,servletResponse);
    }

    @Override
    public void destroy() {

    }
}
